package com.zzj.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzj.entity.Nurse;
import com.zzj.mapper.NurseMapper;
import com.zzj.service.INurseService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zzj
 * @since 2023-05-12
 */
@Service
public class NurseServiceImpl extends ServiceImpl<NurseMapper, Nurse> implements INurseService {

    @Override
    public Nurse getNurseByUsername(String username) {
        return this.getOne(Wrappers.<Nurse>lambdaQuery()
                        .eq(Nurse::getUsername, username),
                false);
    }

    @Override
    public Nurse getNurseById(int id) {
        return this.getOne(Wrappers.<Nurse>lambdaQuery()
                        .eq(Nurse::getId, id),
                false);
    }

    @Override
    public boolean setNurseStatus(String username,int status) {
        return this.lambdaUpdate()
                .eq(Nurse::getUsername, username)
                .set(Nurse::getStatus,status).update();
    }
}
